package com.tzx.lifehousekeeper.controller;

import com.tzx.lifehousekeeper.model.dto.UserDto;
import com.tzx.lifehousekeeper.model.entity.UserEntity;
import com.tzx.lifehousekeeper.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * @Author tuzongxun
 * @Date 2021/9/22
 */
@RestController
@RequestMapping("/user")
@Slf4j
@CrossOrigin
public class UserController {

	@Autowired
	private UserService userService;

	@GetMapping
	public List<UserDto> findUsers(){
		log.info("查询用户列表");
		//List<UserModel> list=new ArrayList<>();
		//list.add(new UserModel("1","tzx","涂宗勋",new Date(),"13535353333","soft develop",0));
		//list.add(new UserModel("2","zs","张三",new Date(),"13535352222","soft test",0));
		return userService.findUsers();
	}

	@GetMapping("/details")
	public UserDto findUser(String userId){
		log.info("查询用户详情："+userId);
		return null;
	}

	@PostMapping
	public String addUser(@RequestBody UserDto userDto){
		log.info("增加用户："+ userDto);
		return userService.addUser(userDto);
	}

	@PutMapping
	public String updateUser(@RequestBody UserDto userDto){
		log.info("修改用户信息,入参："+ userDto);
		return userDto.getId();
	}

	@DeleteMapping
	public String deleteUser(String userId){
		log.info("删除用户："+userId);
		return userId;
	}
}
